Skip to main content

String and Template

New String Methods

console.log('abc'.startsWith( 'a' )); // true

console.log('abc'.endsWith( 'c' )); // true

console.log('good or bad'.includes( ' or ' ));
//> true

console.log('ha '.repeat( 4 ));
//> 'hahahaha'

for(let i = 0; i < 100;i++) {
console.log('Hello'.repeat(100))
}

Template Literals

tip

The purpose of template literals is to evaluate and insert values of JavaScript expressions in a template string.

let key = 'something'
console.log(`${key} in it`)